import { Color, Material } from "cesium"
const shaderSource =
  "czm_material czm_getMaterial(czm_materialInput materialInput)\n\
        {\n\
            czm_material material = czm_getDefaultMaterial(materialInput);\n\
            vec2 st = materialInput.st;\n\
            vec4 colorImage = texture(image, vec2(fract(st.s - time), st.t));\n\
            material.alpha = colorImage.a * color.a;\n\
            material.diffuse = (colorImage.rgb+color.rgb)/2.0;\n\
            return material;\n\
        }"
const image = ``

/**
 * 流光线材质
 *
 * @class
 * @author Spring
 * @since 2024/11/4
 */
export class FlowLightLineMaterial extends Material {
  /**
   * 构造流光线材质
   *
   * @param options 选项。
   * @constructor
   */
  constructor(
    options: {
      type?: string
      color?: Color
      duration?: number
    } = {},
  ) {
    const newOptions = {
      fabric: {
        type: "RadarScanCircle",
        uniforms: {
          color: options.color || new Color(0, 1, 1),
          time: 0,
          image,
        },
        source: shaderSource,
      },
      translucent: true,
    }
    super(newOptions)
  }
}
